import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/6/22 21:54
 */
public class Main {
    public static void main(String[] args) {
        fun44();
    }
    //noob44 数组计数维护
    public static void fun44(){
        int s = 0,cnt =0;
        Scanner sc = new Scanner(System.in);
        //有n组数据
        int i = sc.nextInt();
        while (i != 0){
            cnt = 0;
            s = 0;
            i--;

            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] arr = new int[n];

            for (int j = 0; j < n; j++){
                arr[j] = sc.nextInt();
                if (arr[j] >= k){
                    s = s+arr[j];
                } else if ((arr[j] == 0) && (s >= 1)) {
                    s = s-1;
                    cnt = cnt+1;
                }
            }
            System.out.println(cnt);
        }
    }

    //noob45 计数问题
    public static void fun45(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++){
            int j = i;
            while (j != 0){
                if (j % 10 == k){
                    count++;
                }
                j = j / 10;
            }
        }
        System.out.println(count);
    }

    //noob46 约瑟夫环
    public static void fun46(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int m = sc.nextInt();

        ArrayList<Integer> arr = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            arr.add(i);
        }

        while (arr.size() > 1){
            k = (k+m-1)%arr.size();
            arr.remove(k);
        }
        if (arr.size() ==1){
            System.out.println(arr.get(0));
        }

    }

    //noob47 校门外的树
    public static void fun47(){
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int M = sc.nextInt();

        int[] arr = new int[L+1];
        int sum = 0;
        for (int i = 0; i < M; i++) {
            int left = sc.nextInt();
            int right = sc.nextInt();

            for (int j = left; j <= right ; j++) {
                if (arr[j] == 0){
                    arr[j] = 1;
                    sum += 1;
                }
            }
        }
        System.out.println(L-sum+1);
    }

    //noob48 单组_二维数组
    public static void fun48(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        long sum = 0;
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = sc.nextInt();
                sum += arr[i][j];
            }
        }
        System.out.println(sum);
    }

    //noob49 上三角矩阵判定
    public static void fun49(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n][n];
        int count = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                arr[i][j] = sc.nextInt();
                if (i>j && arr[i][j] == 0){
                    count++;
                }
            }
        }
        if (count == n*(n-1)/2){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

    //noob50 矩阵转置
    public static void fun50(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] arr = new int[n][m];
        int[][] arr1 = new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = sc.nextInt();
                arr1[j][i] = arr[i][j];
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(arr1[i][j]+" ");
            }
            System.out.println();
        }
    }

    //noob51 杨辉三角
    public static void fun51(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ans(n);
    }
    public static void ans(int n){
        int l = n;//行数
        for (int i = 0; i < l; i++) {
            long num = 1;
            for (int j = 0; j <= i ; j++) {
                System.out.println(num + " ");
                num = num *(i-j)/(j+1);
            }
            System.out.println();
        }
    }


    //noob52 扫雷
    public static void fun52(){
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            in.nextLine(); // 消耗换行符
            //定义个大一圈的数组
            char[][] arr = new char[n + 2][m + 2];
            //先把一圈 .装进去
            for (int i = 0; i < n + 2; i++) {
                for (int j = 0; j < m + 2; j++) {
                    if (i == 0 || j == 0 || i == n+1 || j == m+1) {
                        arr[i][j] = '.';
                    }
                }
            }
            //再赋值内圈
            for (int i = 1; i < n + 1; i++) {
                String str = in.nextLine();
                char[] ch = str.toCharArray();
                for (int j = 1; j < m + 1; j++) {
                    arr[i][j]=ch[j-1];
                }
            }
            //定义arr1装结果
            char[][] arr1 = arr;
            //遍历内圈
            for (int i = 1; i < n+1; i++) {
                for (int j = 1; j < m+1; j++) {
                    int res = 0;
                    if (arr[i][j] != '*') {
                        for (int k = i - 1; k <= i + 1; k++) {
                            for (int l = j - 1; l <= j + 1; l++) {
                                if ("*".equals(String.valueOf(arr[k][l]))) {
                                    res++;
                                }
                            }
                        }
                        arr1[i][j] =(char)(res + '0');
                    }
                }
            }
            //输出结果arr1
            for (int i = 1; i < n+1; i++) {
                for (int j = 1; j < m+1; j++) {
                    System.out.print(arr1[i][j]);
                }
                System.out.println();
            }
        }
    }
}
